package com.snack.system.controller;

import com.snack.common.core.web.controller.BaseController;
import com.snack.common.core.web.domain.AjaxResult;
import com.snack.common.core.web.page.TableDataInfo;
import com.snack.common.log.annotation.Log;
import com.snack.common.log.enums.BusinessType;
import com.snack.common.security.annotation.RequiresPermissions;
import com.snack.system.domain.TsUserWx;
import com.snack.system.service.ITsUserWxService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 微信用户Controller
 * 
 * @author snack
 * @date 2022-09-18
 */
@RestController
@RequestMapping("/wx")
public class TsUserWxController extends BaseController
{
    @Autowired
    private ITsUserWxService userWxService;

    /**
     * 查询微信用户列表
     */
    @RequiresPermissions("system:wx:list")
    @GetMapping("/list")
    public TableDataInfo list(TsUserWx tsUserWx)
    {
        startPage();
        List<TsUserWx> list = userWxService.selectList(tsUserWx);
        return getDataTable(list);
    }


    /**
     * 获取微信用户详细信息
     */
    @RequiresPermissions("system:wx:query")
    @GetMapping(value = "/{userWxId}")
    public AjaxResult getInfo(@PathVariable("userWxId") Long userWxId)
    {
        return AjaxResult.success(userWxService.selectById(userWxId));
    }


    /**
     * 修改微信用户
     */
    @RequiresPermissions("system:wx:edit")
    @Log(title = "微信用户", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TsUserWx userWx)
    {
        return toAjax(userWxService.update(userWx));
    }

    /**
     * 删除微信用户
     */
    @RequiresPermissions("system:wx:remove")
    @Log(title = "微信用户", businessType = BusinessType.DELETE)
	@DeleteMapping("/{userWxIds}")
    public AjaxResult remove(@PathVariable Long[] userWxIds)
    {
        return toAjax(userWxService.deleteByIds(userWxIds));
    }
}
